ioemu: Let the USB tablet reach the far bottom and right pixels
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 11:10:29 +0000 (11:10 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 11:10:29 +0000 (11:10 +0000)
by fixing divisions / multiplications into using width-1.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
tools/ioemu/hw/xenfb.c
tools/ioemu/sdl.c
tools/ioemu/vnc.c

index 0d9ab14666649502f4cc6df45205ce26afad7521..affbcaaa0df83e38372909300e42129f214ecb20 100644 (file)
@@ -1052,8 +1052,8 @@ static void xenfb_mouse_event(void *opaque,
     struct xenfb *xenfb = opaque;
     if (xenfb->abs_pointer_wanted)
            xenfb_send_position(xenfb,
-                               dx * xenfb->ds->width / 0x7fff,
-                               dy * xenfb->ds->height / 0x7fff,
+                                dx * (xenfb->ds->width - 1) / 0x7fff,
+                                dy * (xenfb->ds->height - 1) / 0x7fff,
                                dz);
     else
            xenfb_send_motion(xenfb, dx, dy, dz);
@@ -1312,8 +1312,8 @@ static void xenfb_kbd_handler(void *opaque)
                         buttons &= ~button;
                     if (kbd_mouse_is_absolute())
                         kbd_mouse_event(
-                                x * 0x7FFF / s->width,
-                                y * 0x7FFF / s->height,
+                                x * 0x7FFF / (s->width - 1),
+                                y * 0x7FFF / (s->height - 1),
                                 0,
                                 buttons);
                     else
index 9f6f90de26195172035a7c58ded39ca32da43519..f9e140d42e4da2d8d3e59ed0705681a5d40f0565 100644 (file)
@@ -331,8 +331,8 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, int state)
        }
 
        SDL_GetMouseState(&dx, &dy);
-       dx = dx * 0x7FFF / width;
-       dy = dy * 0x7FFF / height;
+        dx = dx * 0x7FFF / (width - 1);
+        dy = dy * 0x7FFF / (height - 1);
     } else if (absolute_enabled) {
        sdl_show_cursor();
        absolute_enabled = 0;
index 464220dc4b119efa0fabf9fc8286af6fe807319a..edd2bd53dc36d5898044f354a35a1967df557c26 100644 (file)
@@ -1217,8 +1217,8 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y)
        dz = 1;
 
     if (vs->absolute) {
-       kbd_mouse_event(x * 0x7FFF / vs->ds->width,
-                       y * 0x7FFF / vs->ds->height,
+        kbd_mouse_event(x * 0x7FFF / (vs->ds->width - 1),
+                        y * 0x7FFF / (vs->ds->height - 1),
                        dz, buttons);
     } else if (vs->has_pointer_type_change) {
        x -= 0x7FFF;